﻿//-----------------------------------------------------------------------
// <copyright file="MainPage.xaml.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics.Silverlight.Studio
{
    using System;

    using System.Windows;
    using System.Windows.Controls;

    using System.Security;
    using System.Security.Principal;

    using CodePlex.Diagnostics.Silverlight;
    using CodePlex.Diagnostics.Silverlight.Contracts;
    using System.ComponentModel;
    
    /// <summary>
    /// Encapsulates the CodePlex.Diagnostics Silverlight application main page.
    /// </summary>
    public partial class MainPage : UserControl
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
        private class SilverlightIdentity : IIdentity
        {
            #region IIdentity Members

            public string AuthenticationType
            {
                get { return "Silverlight"; }
            }

            public bool IsAuthenticated
            {
                get { return true; }
            }

            public string Name
            {
                get { return "Doug Holland"; }
            }

            #endregion
        }

        #region public MainPage()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:MainPage"/> class.
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            try
            {
                for (int index = 0; index < 10; index++)
                {
                    index /= index;
                }
            }
            catch (DivideByZeroException ex)
            {
                ex.Publish(new SilverlightIdentity());
            }

            //TeamFoundationServerDataContract contract = new TeamFoundationServerDataContract(new Uri("http://tfs01.codeplex.com"));

            //DiagnosticsServiceClient client = new DiagnosticsServiceClient();

            ////contract.Assembly = new AssemblyDataContract(Assembly.GetExecutingAssembly());

            //client.RegisterTeamFoundationServerCompleted += delegate(object sender, AsyncCompletedEventArgs e)
            //{
            //};

            //client.RegisterTeamFoundationServerAsync(contract);
        }

        #endregion
    }
}
